//
//  UIImageView+CRExtension.m
//  CRChatRoom
//
//  Created by CuiFengshuai on 15/11/28.
//  Copyright © 2015年 SecondGroup. All rights reserved.
//

#import "UIImageView+CRExtension.h"
#import "UIImageView+WebCache.h"
#import "UIImage+ImageEffects.h"
@implementation UIImageView (CRExtension)

- (void)setHeaderWithUrl:(NSString *)url {
    // 如果图片下载失败,imageView要显示占位图片
    UIImage *placeholder = [[UIImage imageNamed:@"defaultUserIcon"] circleImage];
    
    [self sd_setImageWithURL:[NSURL URLWithString:url] placeholderImage:placeholder completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
        // 图片下载失败, 直接返回 保持默认的占位图片
        if (image == nil) {
            return ;
        }
        self.image = [image circleImage];
    }];
}

@end
